package Offer;

/**
 * 股票的最大利润
 * @author 是阿秋啊
 * @date 2022/04/06 21:50
 **/
public class Num63 {
    public int maxProfit(int[] prices) {
        int max = 0;
        int cost = Integer.MAX_VALUE;
        for (int i = 0; i < prices.length; i++) {
            cost = Math.min(cost,prices[i]);
            max = Math.max(max,prices[i] - cost);
        }
        return max;
    }
}
